home *** CD-ROM | disk | FTP | other *** search
- program Demo;
-
- { This program demonstrates the use of the units HIRESTMR and
- PROFIT under DOS. Compile this program with BP7.
-
- IMPORTANT - set the conditional define 'TMPR' before compiling
- and running to enable the profiler.
- }
-
-
- {$I LibDef.inc}
-
-
- uses
- {$IFDEF TargetDelphi1}
- WinCrt,
- {$ENDIF}
-
- HiResTmr,
- Profit;
-
-
- {$IFDEF TargetDelphi2}
- {$APPTYPE CONSOLE}
- {$ENDIF}
-
- const
- {$IFDEF TargetDelphi1}
- s_Target = '16-bit windows by Delphi1';
- {$ENDIF}
-
- {$IFDEF TargetDelphi2}
- s_Target = '32-bit windows by Delphi2';
- {$ENDIF}
-
- {$IFDEF TargetRealMode}
- s_Target = '16-bit DOS Real mode by BP7';
- {$ENDIF}
-
- {$IFDEF TargetProtectedMode}
- s_Target = '16-bit DOS Protected mode by BP7';
- {$ENDIF}
-
-
- var
- I : integer;
- L : longint;
-
- begin
- Writeln;
- Writeln;
- Writeln( '> Demonstration of HIRESTMR timer unit and PROFIT profiler unit. <' );
- Writeln( ' (C) B.J.Frost 1997' );
- Writeln( ' Compiled for ' + s_Target );
- If b_WindowsInstalled then
- Writeln( ' Windows version is ', w_WindowsVersion )
- else
- Writeln( ' Running under DOS.' );
-
-
- Writeln( ' This shows various methods to achieve a 1s delay with a' );
- Writeln( ' high resolution ..' );
- Writeln;
- Writeln( ' On this PC the minimum accurate delay is ',
- 1e6 * (r_CounterCallOverhead.QuadPart / r_CountsPerSec.QuadPart) : 0 : 1,
- 'us' );
-
-
- { Open the profiler clock }
- TMPROpen( 'TIMES.TXT', 100 );
-
-
- { First 1s delay using a floating-point value }
-
- Write( ' Single 1s delay .. ' );
-
- { Mark this point in the profile output file as '0' }
- TMPRMark( 0 );
-
- { Do the delay .. }
- DelayS( 1.0 );
-
- { Mark this point in the profile output file as '1' }
- TMPRMark( 1 );
-
- Writeln( 'done.' );
-
-
-
- { Second 1s delay calling a 1ms delay routine 1000 times.. }
-
- Write( ' 1s delay from 1000 x 1ms .. ' );
- TMPRMark( 2 );
- For I := 1 to 1000 do
- DelayMS( 1 );
- TMPRMark( 3 );
- Writeln( 'done.' );
-
-
-
- { Third 1s delay calling a 100us delay routine 10,000 times.. }
-
- Write( ' 1s delay from 10,000 x 100us .. ' );
- TMPRMark( 4 );
- For I := 1 to 10000 do
- DelayUS( 100 );
- TMPRMark( 5 );
- Writeln( 'done.' );
-
-
-
- { This calls a 10us delay routine 100,000 times.. }
-
- Write( ' 1s delay from 100,000 x 10us .. ' );
- TMPRMark( 6 );
- For L := 1 to 100000 do
- DelayUS( 10 );
- TMPRMark( 7 );
- Writeln( 'done.' );
-
-
-
- { Closes the timing profiler }
- TMPRClose;
-
- Writeln( ' See file TIMES.TXT for timings of these delays.' );
- Writeln( ' Press a key ..' );
- Readln;
-
- end.
-
-
-
-
-
-
-